//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing.Diagram
{
    class NumericRule: IOfficeXmlSerializable
    {
        readonly ConstraintAttributes _constraintAttributes = new ConstraintAttributes();
        private double _val;
        private double _fact;
        private double _max;

        public void ReadXml(ReadContext context)
        {
            using (var c = context.Read("rule"))
            {
                _constraintAttributes.ReadXml(c);
                _val = c.GetOptionalDouble("val", double.NaN);
                _fact = c.GetOptionalDouble("fact", double.NaN);
                _max = c.GetOptionalDouble("max", double.NaN);
                
            }
        }

        public void WriteXml(WriteContext context)
        {
            using (var c = context.Write("rule"))
            {
                _constraintAttributes.WriteXml(c);
                c.SetOptionalDouble("val", _val , double.NaN);
                c.SetOptionalDouble("fact", _fact , double.NaN);
                c.SetOptionalDouble("max", _max , double.NaN);

            }
        }
    }
}